﻿using System;
using System.Threading;
using ThrottledProcessing.SampleApplication.Interfaces;
using ThrottledProcessing.SampleApplication.Messages;

namespace ThrottledProcessing.SampleApplication.Services
{
    public class AlertService : IAlertService
    {
        private readonly ILoggingService loggingService;

        public AlertService(ILoggingService loggingService)
        {
            this.loggingService = loggingService;
        }

        public ProcessEventResponse ProcessEvent(ProcessEventRequest request)
        {
            loggingService.Debug(string.Format("Processing Event for UserId: {0}", request.UserId));

            // Simulate latency
            Thread.Sleep(DateTime.Now.Millisecond*2);

            return new ProcessEventResponse
                       {
                           EventId = Guid.NewGuid().ToString()
                       };
        }
    }
}